package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlFlange;
import com.ruoyi.hualian.service.IHlFlangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 挡边Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/flange")
public class HlFlangeController extends BaseController
{
    @Autowired
    private IHlFlangeService hlFlangeService;

    /**
     * 查询挡边列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlFlange hlFlange)
    {
        startPage();
        List<HlFlange> list = hlFlangeService.selectHlFlangeList(hlFlange);
        return getDataTable(list);
    }

    /**
     * 导出挡边列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:export')")
    @Log(title = "挡边", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlFlange hlFlange)
    {
        List<HlFlange> list = hlFlangeService.selectHlFlangeList(hlFlange);
        ExcelUtil<HlFlange> util = new ExcelUtil<HlFlange>(HlFlange.class);
        util.exportExcel(response, list, "挡边数据");
    }

    /**
     * 获取挡边详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:query')")
    @GetMapping(value = "/{flangeId}")
    public AjaxResult getInfo(@PathVariable("flangeId") Long flangeId)
    {
        return success(hlFlangeService.selectHlFlangeByFlangeId(flangeId));
    }

    /**
     * 新增挡边
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:add')")
    @Log(title = "挡边", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlFlange hlFlange)
    {
        return toAjax(hlFlangeService.insertHlFlange(hlFlange));
    }

    /**
     * 修改挡边
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:edit')")
    @Log(title = "挡边", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlFlange hlFlange)
    {
        return toAjax(hlFlangeService.updateHlFlange(hlFlange));
    }

    /**
     * 删除挡边
     */
    @PreAuthorize("@ss.hasPermi('hualian:flange:remove')")
    @Log(title = "挡边", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flangeIds}")
    public AjaxResult remove(@PathVariable Long[] flangeIds)
    {
        return toAjax(hlFlangeService.deleteHlFlangeByFlangeIds(flangeIds));
    }
}
